package socket;

import java.io.*;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

/*
* 客户端
* 1.创建客户端对象
* 2.使用Socket对象发送数据
* */
public class Client {
    private Socket socket;

    public Client(){
        try {
            System.out.println("正在连接服务端...");
            socket = new Socket("176.55.4.20",8088);
            System.out.println("连接成功");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void start(){
        try {
            OutputStream os = socket.getOutputStream();
            OutputStreamWriter osw = new OutputStreamWriter(os, StandardCharsets.UTF_8);
            BufferedWriter bw = new BufferedWriter(osw);
            PrintWriter pw = new PrintWriter(bw,true);//自动行刷新
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main(String[] args) {
        Client client = new Client();
        client.start();
    }
}
